package com.xthink.web.controller;

import com.xthink.common.result.AjaxResult;
import com.xthink.common.vo.customer.CustomerInsertVo;
import com.xthink.common.vo.customer.CustomerListVo;
import com.xthink.common.vo.customer.CustomerPageVo;
import com.xthink.common.vo.customer.CustomerUpdateVo;
import com.xthink.web.service.CustomerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/customer")
public class CustomerController {
    @Autowired
    private CustomerService customerService;

    //插入客户
    @PostMapping("/insert")
    public AjaxResult insertOne(@RequestBody CustomerInsertVo customerInsertVo){
        return customerService.insertOne(customerInsertVo);
    }

    //编辑客户
    @PostMapping("/update")
    public AjaxResult updateOne(@RequestBody CustomerUpdateVo customerUpdateVo){
        return customerService.updateOne(customerUpdateVo);
    }

    //删除客户
    @GetMapping("/delete/{id}")
    public AjaxResult deleteOne(@PathVariable("id") Integer id){
        return customerService.deleteOne(id);
    }

    //账号生效
    @GetMapping("/updateTake/{ids}")
    public AjaxResult updateTakeEffect(@PathVariable("ids")Integer[] ids){
        return customerService.updateTakeEffect(ids);
    }

    //账号失效
    @GetMapping("/updateInvalid/{ids}")
    public AjaxResult updateInvalid(@PathVariable("ids")Integer[] ids){
        return customerService.updateInvalid(ids);
    }

    //模糊查询
    @PostMapping("/list")
    public AjaxResult likeList(@RequestBody CustomerListVo customerListVo){
        return customerService.likeList(customerListVo);
    }


    //分页查询
    @PostMapping("/page")
    private AjaxResult pageInfo(@RequestBody CustomerPageVo customerPageVo){
        return customerService.pageInfo(customerPageVo);
    }

    //签约主体下拉框
    @RequestMapping("/signing")
    private AjaxResult signing(){
        return customerService.signing();
    }

}
